package com.pureut.storage.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pureut.common.core.utils.bean.BeanUtils;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.security.utils.DictUtils;
import com.pureut.storage.domain.*;
import com.pureut.storage.domain.system.domain.*;
import com.pureut.storage.dto.*;
import com.pureut.storage.mapper.*;
import com.pureut.storage.service.WarehouseSignageService;
import com.pureut.system.api.FeignService;
import com.pureut.system.api.RemoteUserService;
import com.pureut.system.api.domain.MaterialCodingDto;
import com.pureut.system.api.domain.SysDictData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.temporal.Temporal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author: YSL
 * @Date: 2023/5/4 10:42
 * @Desc: 仓库看板
 */
@Service
public class WarehouseSignageServiceImpl implements WarehouseSignageService {

    /**
     * 仓库建模
     */
    @Resource
    WarehouseMapper warehouseMapper;

    /**
     * 仓库看板
     */
    @Resource
    WarehouseSignageMapper warehouseSignageMapper;

    /**
     * 采购退货明细Mapper
     */
    @Resource
    PickingPurchaseDetailMapper pickingPurchaseDetailMapper;

    /**
     * 委外退货明细mapper
     */
    @Resource
    PickingReturnsDetailMapper pickingReturnsDetailMapper;

    /**
     * 库存信息
     */
    @Resource
    WmsStockInfoMapper wmsStockInfoMapper;

    /**
     * 系统配置远程调用
     */
    @Resource
    FeignService feignService;

    /**
     * 远程调用
     */
    @Resource
    RemoteUserService remoteUserService;

    /**
     * 获取仓库列表
     *
     * @return
     */
    @Override
    public List<WarehouseBulletinBoardDto> getWarehouseBulletinBoard(String warehouseCode) {

        List<WarehouseBulletinBoardDto> list = new ArrayList<>();
        //获取仓库列表
        List<WarehouseSignageDto> warehouse = warehouseSignageMapper.getWarehouseBulletinBoard(warehouseCode);

        for (WarehouseSignageDto ck : warehouse) {
            WarehouseBulletinBoardDto warehouseBulletinBoardDto = new WarehouseBulletinBoardDto();
            //库区列表
            List<ReservoirAreaDto> reservoirAreaDtoList = new ArrayList<>();
            //获取仓库下的库区
            List<Warehouse> warehouses = warehouseMapper.selectList(new QueryWrapper<Warehouse>().lambda().eq(Warehouse::getParentCode, ck.getWarehouseCode()).eq(Warehouse::getWarehouseType, 2));

            for (Warehouse kq : warehouses) {
                if (ck.getWarehouseCode().equals(kq.getParentCode())) {
                    ReservoirAreaDto reservoirAreaDto = new ReservoirAreaDto();
                    BeanUtils.copyProperties(kq, reservoirAreaDto);
                    reservoirAreaDto.setVolume(String.valueOf(kq.getVolume()));
                    reservoirAreaDto.setCapacity(String.valueOf(kq.getCapacity()));
                    reservoirAreaDto.setWarehouseType(String.valueOf(kq.getWarehouseType()));
                    reservoirAreaDtoList.add(reservoirAreaDto);
                }
                ck.setChildren(reservoirAreaDtoList);

            }

            //循环库区
            int size = 0;
            for (ReservoirAreaDto kqList : reservoirAreaDtoList) {
                List<Warehouse> kw = warehouseMapper.selectList(new QueryWrapper<Warehouse>().lambda().eq(Warehouse::getParentCode, kqList.getWarehouseCode()).eq(Warehouse::getWarehouseType, 3));
                int sizeList = kw.size();
                warehouseBulletinBoardDto.setWareLocationNumber(sizeList);
                size += warehouseBulletinBoardDto.getWareLocationNumber();
            }

            // 获取人员信息
            AjaxResult ajaxResult = remoteUserService.selectSysUserById(ck.getResponsiblePerson());
            SysUser data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), SysUser.class);

            warehouseBulletinBoardDto.setReservoirAreaNumber(warehouses.size());
            warehouseBulletinBoardDto.setWareLocationNumber(size);
            warehouseBulletinBoardDto.setWarehouseName(ck.getWarehouseName());
            warehouseBulletinBoardDto.setPhoto(data.getAvatar());
            warehouseBulletinBoardDto.setWarehouseManager(data.getNickName());

            list.add(warehouseBulletinBoardDto);

        }
        return list;
    }

    /**
     * 仓库库存情况
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public WarehouseInventorySituationDto getWarehouseInventorySituationNumber(String warehouseCode) {

        WarehouseInventorySituationDto warehouseInventorySituationDto = new WarehouseInventorySituationDto();
        // 根据仓库编码查询仓库建模信息
        WarehouseDto warehouseDto = warehouseMapper.selectWarehouseInfo(warehouseCode);

        // 生产领料明细（累积出库数量）
        WarehouseInventorySituationDto newStockInfoDetailNumber = warehouseSignageMapper.getNewStockInfoDetailNumber(warehouseDto.getWarehouseName());
        // 委外发货明细（累积出库数量）
        WarehouseInventorySituationDto pickingOutsourceDetailNumber = warehouseSignageMapper.getPickingOutsourceDetailNumber(warehouseDto.getWarehouseName());
        // 销售发货明细（累积出库数量）
        WarehouseInventorySituationDto pickingSaleDetailNumber = warehouseSignageMapper.getPickingSaleDetailNumber(warehouseDto.getWarehouseName());
        // 返工出库明细（累积出库数量）
        WarehouseInventorySituationDto pickingCompleteDetailNumber = warehouseSignageMapper.getPickingCompleteDetailNumber(warehouseDto.getWarehouseName());
        // 采购退货明细（累积出库数量）
        WarehouseInventorySituationDto pickingPurchaseDetailNumber = warehouseSignageMapper.getPickingPurchaseDetailNumber(warehouseDto.getWarehouseName());
        // 委外退货明细（累积出库数量）
        WarehouseInventorySituationDto pickingReturnsDetailNumber = warehouseSignageMapper.getPickingReturnsDetailNumber(warehouseDto.getWarehouseName());
        // 其他出库明细（累积出库数量）
        WarehouseInventorySituationDto pickingRestDetailNumber = warehouseSignageMapper.getPickingRestDetailNumber(warehouseDto.getWarehouseName());

        // 出库净重
        BigDecimal addSum = newStockInfoDetailNumber.getOutboundQuantity().add(pickingOutsourceDetailNumber.getOutboundQuantity().add(pickingSaleDetailNumber.getOutboundQuantity().add(pickingCompleteDetailNumber.getOutboundQuantity().add(pickingPurchaseDetailNumber.getOutboundQuantity()
                .add(pickingReturnsDetailNumber.getOutboundQuantity().add(pickingRestDetailNumber.getOutboundQuantity()))))));
        // 转换成吨
        BigDecimal bigDecimal1 = new BigDecimal(1000);
        BigDecimal divide = addSum.divide(bigDecimal1, BigDecimal.ROUND_HALF_UP);

        // 1、累积出库数量
        warehouseInventorySituationDto.setOutboundQuantity(divide);

        // 采购入库明细（累积入库数量）
        WarehouseInventorySituationDto purchaseReceiptDetailNumber = warehouseSignageMapper.getPurchaseReceiptDetailNumber(warehouseDto.getWarehouseName());
        // 销售退货明细（累积入库数量）
        WarehouseInventorySituationDto salesReturnDetailNumber = warehouseSignageMapper.getSalesReturnDetailNumber(warehouseDto.getWarehouseName());
        // 生产退料明细（累积入库数量）
        WarehouseInventorySituationDto productionMaterialReturnDetailNumber = warehouseSignageMapper.getProductionMaterialReturnDetailNumber(warehouseDto.getWarehouseName());
        // 完工入库明细（累积入库数量）
        WarehouseInventorySituationDto wipCompletionDetailNumber = warehouseSignageMapper.getWipCompletionDetailNumber(warehouseDto.getWarehouseName());
        // 其他入库明细（累积入库数量）
        WarehouseInventorySituationDto miscellaneousReceiptDetailNumber = warehouseSignageMapper.getMiscellaneousReceiptDetailNumber(warehouseDto.getWarehouseName());
        // 委外入库明细（累积入库数量）
        WarehouseInventorySituationDto subcontractReceiptDetailNumber = warehouseSignageMapper.getSubcontractReceiptDetailNumber(warehouseDto.getWarehouseName());

        // 累积入库净重
        BigDecimal addSum1 = purchaseReceiptDetailNumber.getReceivedQuantity().add(salesReturnDetailNumber.getReceivedQuantity().add(productionMaterialReturnDetailNumber.getReceivedQuantity().add(wipCompletionDetailNumber.getReceivedQuantity()
                .add(miscellaneousReceiptDetailNumber.getReceivedQuantity().add(subcontractReceiptDetailNumber.getReceivedQuantity())))));

        BigDecimal divide1 = addSum1.divide(bigDecimal1, BigDecimal.ROUND_HALF_UP);
        // 2、累积入库数量
        warehouseInventorySituationDto.setReceivedQuantity(divide1);

        // 查询库存数量
        WarehouseInventorySituationDto warehouseInventorySituationDto1 = warehouseSignageMapper.selectWmsStockInfoNumber(warehouseDto.getId());
        BigDecimal divide2 = warehouseInventorySituationDto1.getCurrentInventoryQuantity().divide(bigDecimal1, BigDecimal.ROUND_HALF_UP);
        BigDecimal bigDecimal = divide2.setScale(2, BigDecimal.ROUND_HALF_UP);
        // 3、当前库存内数量
        warehouseInventorySituationDto.setCurrentInventoryQuantity(bigDecimal);

        return warehouseInventorySituationDto;
    }


    /**
     * 仓库库存情况 库存量（吨）
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public List<WarehouseInventoryDto> getWarehouseInventory(String warehouseCode) {
        // 根据仓库编码查询仓库建模信息
        WarehouseDto warehouseDto = warehouseMapper.selectWarehouseInfo(warehouseCode);
        // 查询库存净重总和
        List<WarehouseInventoryDto> warehouseInventoryDtos = warehouseSignageMapper.selectWarehouseInventory(warehouseDto.getId());
        for (WarehouseInventoryDto warehouseInventoryDto : warehouseInventoryDtos){
            // 转换成吨
            BigDecimal bigDecimal1 = new BigDecimal(1000);
            BigDecimal divide = warehouseInventoryDto.getInventory().divide(bigDecimal1, 4,BigDecimal.ROUND_HALF_UP);
            warehouseInventoryDto.setInventory(divide);
        }

        return warehouseInventoryDtos;
    }

    /**
     * 本月物料出入库统计
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public List<MaterialStatisticsDto> getMaterialStatisticsList(String warehouseCode) {


        // 根据仓库编码查询仓库建模信息
        WarehouseDto warehouseDto = warehouseMapper.selectWarehouseInfo(warehouseCode);


        // 查询物料类别
        AjaxResult ajaxResult = feignService.selectMaterialCodingList();
        List<MaterialCodingDto> data = JSON.parseArray(JSON.toJSONString(ajaxResult.get("data")), MaterialCodingDto.class);

        // 获取当月的一天
        String startTime = String.valueOf(LocalDate.now().withDayOfMonth(1));

        // 获取当月的最后一天
        String endTime = String.valueOf(LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()));


        List<MaterialStatisticsDto> list = new ArrayList<>();
        for (MaterialCodingDto coding : data) {
            MaterialStatisticsDto materialStatisticsDto = new MaterialStatisticsDto();
            // 每月类别出库数量（生产领料）
            Long materialStatisticsDto1 = warehouseSignageMapper.monthlyStockInfoDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（委外发货）
            Long materialStatisticsDto2 = warehouseSignageMapper.monthlyPickingOutsourceDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（销售发货）
            Long materialStatisticsDto3 = warehouseSignageMapper.monthlyPickingSaleDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（返工出库）
            Long materialStatisticsDto4 = warehouseSignageMapper.monthlyPickingCompleteDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（采购退货）
            Long materialStatisticsDto5 = warehouseSignageMapper.monthlyPickingPurchaseDetailListNumber(warehouseDto.getWarehouseName(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（委外退货）
            Long materialStatisticsDto6 = warehouseSignageMapper.monthlyPickingReturnsDetailListNumber(warehouseDto.getWarehouseName(), coding.getCodingId(), startTime, endTime);
            // 每月类别出库数量（其他出库）
            Long materialStatisticsDto7 = warehouseSignageMapper.monthlyPickingRestDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);


            // 每月类别入库数量（采购入库）
            Long materialStatisticsDto8 = warehouseSignageMapper.warehousingPurchaseReceiptDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别入库数量（销售退货）
            Long materialStatisticsDto9 = warehouseSignageMapper.warehousingSalesReturnDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别入库数量（生产退料）
            Long materialStatisticsDto10 = warehouseSignageMapper.warehousingProductionMaterialReturnDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别入库数量（完工入库）
            Long materialStatisticsDto11 = warehouseSignageMapper.warehousingWipCompletionDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别入库数量（其他入库）
            Long materialStatisticsDto12 = warehouseSignageMapper.warehousingMiscellaneousReceiptDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);
            // 每月类别入库数量（委外入库）
            Long materialStatisticsDto13 = warehouseSignageMapper.warehousingSubcontractReceiptDetailNumber(warehouseDto.getId(), coding.getCodingId(), startTime, endTime);

            // 出库总数
            long outboundNum = materialStatisticsDto1 + materialStatisticsDto2 + materialStatisticsDto3 + materialStatisticsDto4 + materialStatisticsDto5
                    + materialStatisticsDto6 + materialStatisticsDto7;

            // 入库总数
            long warehousingNum = materialStatisticsDto8 + materialStatisticsDto9 + materialStatisticsDto10 + materialStatisticsDto11 + materialStatisticsDto12
                    + materialStatisticsDto13;

            if (outboundNum != 0){
                // 每月类别出库数量总数
                materialStatisticsDto.setMaterialOutboundQuantity(outboundNum);
            }else {
                // 每月类别出库数量总数
                materialStatisticsDto.setMaterialOutboundQuantity(0L);
            }

            if (warehousingNum != 0){
                // 每月类别出库数量总数
                materialStatisticsDto.setMaterialReceiptQuantity(warehousingNum);
            } else {
                // 每月类别出库数量总数
                materialStatisticsDto.setMaterialReceiptQuantity(0L);
            }

            if(outboundNum != 0 || warehousingNum != 0){
                // 物料类别
                materialStatisticsDto.setMaterialCategory(coding.getCodingRules());
                list.add(materialStatisticsDto);
            }
        }

        return list;
    }

    /**
     * 库区物料情况
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public List<WarehouseMaterialsSituationDto> getWarehouseMaterialsSituationList(String warehouseCode) {
        //获取仓库列表
        List<WarehouseSignageDto> warehouse = warehouseSignageMapper.getWarehouseBulletinBoard(warehouseCode);

        List<WarehouseMaterialsSituationDto> list = new ArrayList<>();
        for (WarehouseSignageDto ck : warehouse) {
            //库区列表
            List<ReservoirAreaDto> reservoirAreaDtoList = new ArrayList<>();
            //获取仓库下的库区
            List<Warehouse> warehouses = warehouseMapper.selectList(new QueryWrapper<Warehouse>().lambda().eq(Warehouse::getParentCode, ck.getWarehouseCode()).eq(Warehouse::getWarehouseType, 2));
            for (Warehouse kq : warehouses) {
                if (ck.getWarehouseCode().equals(kq.getParentCode())) {
                    ReservoirAreaDto reservoirAreaDto = new ReservoirAreaDto();
                    BeanUtils.copyProperties(kq, reservoirAreaDto);
                    reservoirAreaDto.setVolume(String.valueOf(kq.getVolume()));
                    reservoirAreaDto.setCapacity(String.valueOf(kq.getCapacity()));
                    reservoirAreaDto.setWarehouseType(String.valueOf(kq.getWarehouseType()));
                    reservoirAreaDtoList.add(reservoirAreaDto);
                }
                ck.setChildren(reservoirAreaDtoList);
            }

            for (ReservoirAreaDto reservoirAreaDto : reservoirAreaDtoList) {
                List<WarehouseMaterialsSituationDto> warehouseMaterialsSituationList = warehouseSignageMapper.getWarehouseMaterialsSituationList(reservoirAreaDto.getId());
                for (WarehouseMaterialsSituationDto warehouseMaterialsSituationDto : warehouseMaterialsSituationList) {
                    // 查询库区
                    Warehouse warehouse1 = warehouseMapper.selectOne(new QueryWrapper<Warehouse>().lambda().eq(Warehouse::getId, warehouseMaterialsSituationDto.getWarehouseAreaCode()));
                    warehouseMaterialsSituationDto.setWarehouseAreaCode(warehouse1.getWarehouseName());

                    //  查询物料类别
                    if (warehouseMaterialsSituationDto.getMaterialCategory()!=null){
                        AjaxResult ajaxResult = feignService.selectCodingRulesById(String.valueOf(warehouseMaterialsSituationDto.getMaterialCategory()));
                        MaterialCodingDto data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialCodingDto.class);
                        warehouseMaterialsSituationDto.setMaterialCategory(data.getCodingRules());
                    }
                    list.add(warehouseMaterialsSituationDto);
                }
            }

        }

        return list;
    }

    /**
     * 库存周转率
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public List<InventoryTurnoverRateDto> getInventoryTurnoverRateList(String warehouseCode) {

        // 获取仓库列表
        List<WarehouseSignageDto> warehouse = warehouseSignageMapper.getWarehouseBulletinBoard(warehouseCode);
        // 创建日期格式化对象
        SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd");

        // 获取当前时间所在的Calendar对象
        Calendar calendar = Calendar.getInstance();

        // 获取当前日期
        LocalDate today = LocalDate.now();

        // 七天前的日期
        LocalDate weekAgo = today.minusDays(7);

        List<InventoryTurnoverRateDto> list = new ArrayList<>();

        // 循环输出当前时间及过去七天的时间
        for (int i = 0; i < 7; i++) {
            String format = sdfDateTime.format(calendar.getTime());
            calendar.add(Calendar.DATE, -1);

            for (WarehouseSignageDto WarehouseSignageDto : warehouse) {
                InventoryTurnoverRateDto inventoryTurnoverRateDto = new InventoryTurnoverRateDto();
                // 期初库存数量
                Long openingInventoryNumber = warehouseSignageMapper.getOpeningInventoryNumber(format, WarehouseSignageDto.getId());
                // 期末库存数量
                Long endingInventoryNumber = warehouseSignageMapper.getEndingInventoryNumber(today, weekAgo, WarehouseSignageDto.getId());
                BigDecimal s = BigDecimal.valueOf(openingInventoryNumber + endingInventoryNumber);

                // 定义时段天数
                BigDecimal daySum = BigDecimal.valueOf(3.5);

                // 生产领料
                Long periodTimeNewStockInfoNumber = warehouseSignageMapper.getPeriodTimeNewStockInfoNumber(today, LocalDate.parse(format), WarehouseSignageDto.getId());
                // 委外发货
                Long periodTimePickingOutsourceNumber = warehouseSignageMapper.getPeriodTimePickingOutsourceNumber(today, LocalDate.parse(format), WarehouseSignageDto.getId());
                // 销售发货
                Long periodTimePickingSaleNumber = warehouseSignageMapper.getPeriodTimePickingSaleNumber(today, LocalDate.parse(format), WarehouseSignageDto.getId());
                // 返工出库
                Long periodTimePickingCompleteNumber = warehouseSignageMapper.getPeriodTimePickingCompleteNumber(today, LocalDate.parse(format), WarehouseSignageDto.getId());
                // 采购退货
                Long periodTimePickingPurchaseNumber = warehouseSignageMapper.getPeriodTimePickingPurchaseNumber(today, LocalDate.parse(format), WarehouseSignageDto.getWarehouseName());
                // 委外退货
                Long periodTimePickingReturnsNumber = warehouseSignageMapper.getPeriodTimePickingReturnsNumber(today, LocalDate.parse(format), WarehouseSignageDto.getWarehouseName());
                // 其他出库
                Long periodTimePickingRestNumber = warehouseSignageMapper.getPeriodTimePickingRestNumber(today, LocalDate.parse(format), WarehouseSignageDto.getId());

                // 时段出库数
                BigDecimal periodOfTimeNumber = BigDecimal.valueOf(periodTimeNewStockInfoNumber + periodTimePickingOutsourceNumber + periodTimePickingSaleNumber + periodTimePickingCompleteNumber + periodTimePickingPurchaseNumber
                        + periodTimePickingReturnsNumber + periodTimePickingRestNumber);

                if (s.compareTo(BigDecimal.ZERO) == 0 || periodOfTimeNumber.compareTo(BigDecimal.ZERO) == 0) {
                    inventoryTurnoverRateDto.setInventoryTurnoverRate(BigDecimal.valueOf(0));
                } else {
                    BigDecimal multiply = daySum.multiply(s);
                    BigDecimal divide = multiply.divide(periodOfTimeNumber, BigDecimal.ROUND_HALF_UP);
                    inventoryTurnoverRateDto.setInventoryTurnoverRate(divide);
                }


                // 近七天库存周转率保留两位数
                inventoryTurnoverRateDto.setCurrentTime(format);

                list.add(inventoryTurnoverRateDto);
            }

        }

        return list;
    }

    /**
     * 仓库告警信息
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public WarehouseAlarmInformationDto alarmInformationList(String warehouseCode) {

        // 获取仓库列表
        WarehouseSignageDto warehouse = warehouseSignageMapper.getWarehouseBulletinBoardInfo(warehouseCode);

        // 获取库存信息
        List<WmsStockInfo> wmsStockInfos = wmsStockInfoMapper.selectAlarmInformationById(warehouse.getId());

        //  查询物料生产时间和入库时间
        List<WmsStockInfo> wmsStockInfos1 = warehouseSignageMapper.selectWarehouseBulletinList(warehouse.getId());

        // 保质期数
        int materialQualityNumber = 0;
        // 库存预警数
        int materialMinSecurityNumber = 0;
        // 库存复检数
        int materialInspectionNumber = 0;

        for (WmsStockInfo wmsStockInfo : wmsStockInfos) {

            WarehouseAlarmInformationDto warehouseAlarmInformationDto = new WarehouseAlarmInformationDto();

            // 获取当前时间和保质期的间隔
            LocalDate today = LocalDate.now();

            // 1、当物料类别为原料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 1) {

                // 原料信息
                AjaxResult ajaxResult = feignService.selectAllByAlarmMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAwmateria data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAwmateria.class);

                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(0);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }


                // 2、获取最小安全库存
                Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                    warehouseAlarmInformationDto.setMaterialMinSecurityNumber(1);
                    materialMinSecurityNumber += warehouseAlarmInformationDto.getMaterialMinSecurityNumber();
                } else {
                    warehouseAlarmInformationDto.setMaterialMinSecurityNumber(0);
                    materialMinSecurityNumber += warehouseAlarmInformationDto.getMaterialMinSecurityNumber();
                }


                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    // 3、获取库存复检
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(0);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }


            // 2、当物料类别为辅料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 2) {

                // 辅料信息
                AjaxResult ajaxResult = feignService.selectAccessoriesMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAccessories data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAccessories.class);

                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }


                // 2、获取最小安全库存
                Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                    warehouseAlarmInformationDto.setMaterialMinSecurityNumber(1);
                    materialMinSecurityNumber += warehouseAlarmInformationDto.getMaterialMinSecurityNumber();
                }


                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    // 3、获取库存复检
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }

            // 3、当物料类别是半成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 3) {

                // 半成品信息
                AjaxResult ajaxResult = feignService.selectMaterialHalfMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialHalf data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialHalf.class);

                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }


                // 2、获取最小安全库存
                Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                    warehouseAlarmInformationDto.setMaterialMinSecurityNumber(1);
                    materialMinSecurityNumber += warehouseAlarmInformationDto.getMaterialMinSecurityNumber();
                }


                // 3、获取库存复检
                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }

            // 4、当物料类别为成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 4) {

                // 成品
                AjaxResult ajaxResult = feignService.selectMaterialFinishedMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialFinished data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialFinished.class);
                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }


                // 2、获取最小安全库存
                Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                    warehouseAlarmInformationDto.setMaterialMinSecurityNumber(1);
                    materialMinSecurityNumber += warehouseAlarmInformationDto.getMaterialMinSecurityNumber();
                }


                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    // 3、获取库存复检
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }
        }


        // 获取保质期和复检数
        for (WmsStockInfo wmsStockInfo : wmsStockInfos1) {
            WarehouseAlarmInformationDto warehouseAlarmInformationDto = new WarehouseAlarmInformationDto();

            // 获取当前时间和保质期的间隔
            LocalDate today = LocalDate.now();

            // 1、当物料类别为原料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 1) {

                // 原料信息
                AjaxResult ajaxResult = feignService.selectAllByAlarmMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAwmateria data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAwmateria.class);

                // 1、获取物料保质期
                if (wmsStockInfo.getWsiProducedDate() != null) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(0);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }

                // 3、获取库存复检
                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(0);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }

            // 2、当物料类别为辅料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 2) {

                // 辅料信息
                AjaxResult ajaxResult = feignService.selectAccessoriesMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAccessories data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAccessories.class);

                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(0);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }

                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    // 3、获取库存复检
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(0);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }

            // 3、当物料类别是半成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 3) {

                // 半成品信息
                AjaxResult ajaxResult = feignService.selectMaterialHalfMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialHalf data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialHalf.class);

                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(0);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }

                // 3、获取库存复检
                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(0);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }

            // 4、当物料类别为成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 4) {

                // 成品
                AjaxResult ajaxResult = feignService.selectMaterialFinishedMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialFinished data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialFinished.class);
                if (wmsStockInfo.getWsiProducedDate() != null) {
                    // 1、获取物料保质期
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiProducedDate());
                    LocalDate parse = LocalDate.parse(format);
                    LocalDate localDate = parse.plusDays(data.getMaterialQuality());
                    // 获取当前时间和保质期的间隔
                    Period between = Period.between(localDate, today);
                    int days = between.getDays();
                    if (days <= 0) {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(1);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialQualityNumber(0);
                        // 保质期
                        materialQualityNumber += warehouseAlarmInformationDto.getMaterialQualityNumber();
                    }
                }

                if (wmsStockInfo.getWsiReveiveTime() != null) {
                    // 3、获取库存复检
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String format = sdf.format(wmsStockInfo.getWsiReveiveTime());
                    LocalDate parseQuality = LocalDate.parse(format);
                    LocalDate localDateQuality = parseQuality.plusDays(data.getMaterialQuality());
                    // 获取当前时间和库存复检的间隔
                    Period betweenQuality = Period.between(localDateQuality, today);
                    int daysQuality = betweenQuality.getDays();
                    if (daysQuality <= 0) {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(1);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    } else {
                        warehouseAlarmInformationDto.setMaterialInspectionNumber(0);
                        // 库存复检
                        materialInspectionNumber += warehouseAlarmInformationDto.getMaterialInspectionNumber();
                    }
                }
            }
        }


        WarehouseAlarmInformationDto warehouseAlarmInformationDto = new WarehouseAlarmInformationDto();
        warehouseAlarmInformationDto.setMaterialInspectionNumber(materialInspectionNumber);
        warehouseAlarmInformationDto.setMaterialMinSecurityNumber(materialMinSecurityNumber);
        warehouseAlarmInformationDto.setMaterialQualityNumber(materialQualityNumber);

        return warehouseAlarmInformationDto;
    }


    /**
     * 告警内容
     *
     * @param warehouseCode
     * @return
     */
    @Override
    public List<AlarmContentDto> getAlarmContentDtoList(String warehouseCode) {

        // 获取仓库列表
        WarehouseSignageDto warehouse = warehouseSignageMapper.getWarehouseBulletinBoardInfo(warehouseCode);

        // 获取库存信息
        List<WmsStockInfo> wmsStockInfos = wmsStockInfoMapper.selectAlarmInformationById(warehouse.getId());

        List<AlarmContentDto> list = new ArrayList<>();

        for (WmsStockInfo wmsStockInfo : wmsStockInfos) {

            // 当类别是原料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 1) {
                // 原料信息
                AjaxResult ajaxResult = feignService.selectAllByAlarmMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAwmateria data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAwmateria.class);

                List<AlarmContentDto> alarmContentDtoList = warehouseSignageMapper.getAlarmContentDtoList(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                for (AlarmContentDto alarmContentDto : alarmContentDtoList) {
                    Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                    if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                        alarmContentDto.setAlarmDetails("库存低于最小库存量");
                        alarmContentDto.setAlarmStates("待处理");
                        list.add(alarmContentDto);
                    }
                }
            }

            // 当类别是辅料时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 2) {
                // 辅料信息
                AjaxResult ajaxResult = feignService.selectAccessoriesMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialAccessories data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialAccessories.class);

                List<AlarmContentDto> alarmContentDtoList = warehouseSignageMapper.getAlarmContentDtoList(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                for (AlarmContentDto alarmContentDto : alarmContentDtoList) {
                    Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                    if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                        alarmContentDto.setAlarmDetails("库存低于最小库存量");
                        alarmContentDto.setAlarmStates("待处理");
                        list.add(alarmContentDto);
                    }
                }
            }

            // 当类别是半成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 3) {
                // 半成品信息
                AjaxResult ajaxResult = feignService.selectMaterialHalfMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialHalf data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialHalf.class);

                List<AlarmContentDto> alarmContentDtoList = warehouseSignageMapper.getAlarmContentDtoList(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                for (AlarmContentDto alarmContentDto : alarmContentDtoList) {
                    Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                    if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                        alarmContentDto.setAlarmDetails("库存低于最小库存量");
                        alarmContentDto.setAlarmStates("待处理");
                        list.add(alarmContentDto);
                    }
                }
            }

            // 当类别是成品时
            if (Long.parseLong(wmsStockInfo.getWsiCategory()) == 4) {
                // 成品
                AjaxResult ajaxResult = feignService.selectMaterialFinishedMaterialCode(wmsStockInfo.getWsiMaterialCode());
                MaterialFinished data = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), MaterialFinished.class);

                List<AlarmContentDto> alarmContentDtoList = warehouseSignageMapper.getAlarmContentDtoList(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                for (AlarmContentDto alarmContentDto : alarmContentDtoList) {
                    Long inventoryQuantityNumber = warehouseSignageMapper.getInventoryQuantityNumber(warehouse.getId(), wmsStockInfo.getWsiMaterialCode());
                    if (inventoryQuantityNumber <= data.getMaterialMinSecurity()) {
                        alarmContentDto.setAlarmDetails("库存低于最小库存量");
                        alarmContentDto.setAlarmStates("待处理");
                        list.add(alarmContentDto);
                    }
                }
            }

        }

        return list;
    }


}
